﻿namespace DCHealthCheck.MvcWeb.Classes.ViewModels {

    #region Usings
    using DCHealthCheck.Common;
    using DCHealthCheck.DomainModel;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Web;
    #endregion

    public class ResultsViewModel : BaseViewModel {

        #region Members
        public Guid Id {
            get { return this.SystemInfoId; }
            set { this.SystemInfoId = value; }
        }

        public SystemInfo Result {
            get {
                result = null;
                if ((this.Id != Guid.Empty) && (this.Results != null) && (this.Results.Any())) {
                    result = this.Results.First();
                }

                return result;
            }
        }
        private SystemInfo result;

        public List<SystemInfo> Results { get; set; } 
        #endregion

        #region Constructor
        public ResultsViewModel() {
            this.Results = new List<SystemInfo>();
        } 
        #endregion

        #region Methods
        public override void Initialize(){
            Global.DefaultLog.DebugFormat("[ThreadId: {0}] {1}", Thread.CurrentThread.ManagedThreadId, Extensions.CurrentMethodName());

            base.Initialize();
            this.TakeCount = 15;
            this.DisplayDownloadLink = true;

            if (string.IsNullOrWhiteSpace(this.SortColumn)) {
                this.SortColumn = "ErrorMessage";
                this.CurrentSortDirection = System.Web.Helpers.SortDirection.Descending;
            }
        } 
        #endregion

    }
}